package com.all.common.gps;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationProvider;
import android.os.Bundle;
import android.util.Log;

public class GpsLocationListener implements LocationListener {

	protected String TAG = this.getClass().getName();
	
	@SuppressWarnings("unused")
	private Location mLocation;
	
	public GpsLocationListener( Location location)
	{
		this.mLocation = location;
	}
	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
		switch (status) {
		//GPS状态为可见时
		case LocationProvider.AVAILABLE:
			 Log.i(TAG, "当前GPS状态为可见状态");
			break;
		//GPS状态为服务区外时
		case LocationProvider.OUT_OF_SERVICE:
			 Log.i(TAG, "当前GPS状态为服务区外状态");
			break;
		//GPS状态为暂停服务时
		default : 
			 Log.i(TAG, "当前GPS状态为暂停服务状态");
			break;
		}
	}
	/**
     * GPS开启时触发
     */
	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
		/*
		 * 调用定位时触发
		 * 供应商（provider）可以时触发
		 * */
		//mLocation = mLocationManager.getLastKnownLocation(provider);
	}
	/**
     * GPS禁用时触发
     */
	@Override
	public void onProviderDisabled(String arg0) {
		// TODO Auto-generated method stub
	}
	/**
     * GPS重新定位
     */
	@Override
	public void onLocationChanged(Location location) {
		// TODO Auto-generated method stub
		/*
		 * 定位改变时触发
		 * 通过getLastLocation()或requestLocationUpdates()触发
		 * 获取定位location
		 * */
		this.mLocation = location;
	}

}
